<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
    <store/>
  </div>
</template>

<script>
// @ is an alias to /src
import store from './store'

export default {
  name: 'Home',
  components: {
    store
  },
  //渲染该组件路由被确认前调用 里面没有this
  beforeRouteEnter(to,from,next){
    console.log(from)
    next(vm=>{
      console.log(vm);//这个vm就是这个组件的实例可以代替this
    })
  },
  // 离开当前组件的钩子
  beforeRouteLeave(to,from,next){
    const leave = confirm('您确定要离开吗')
    if(leave) next()
    else next(false)
  }
}
</script>
